package com.fc.push.handler.pub.service;

import java.util.ArrayList;
import java.util.Set;

import com.alibaba.fastjson.JSONObject;
import com.fc.commons.JsonUtils;
import com.fc.push.handler.pub.exec.PublishTaskPool;
import com.fc.push.handler.pub.exec.task.WebPublishTask;
import com.fc.push.logger.Applogger;
public class WebPublishService {

	private WebPublishService() {

	}

	private static class Instance {
		private static WebPublishService service = new WebPublishService();
	}

	public static WebPublishService getInstance() {
		return Instance.service;
	}
	
	/**
	 * 推送消息
	 * @param ids
	 * @param msg
	 */
	public void pubMessageBySlice(Set<String> ids, JSONObject msg) {
		Applogger.instance().getLogger().info(JsonUtils.object2String(msg));
		PublishTaskPool.Instance.getInstance().submit(new WebPublishTask(new ArrayList<String>(ids), msg));
	}
	
	/**
	 * 推送消息
	 * @param ids
	 * @param msg
	 */
	public void pubMessageBySlice(Object[] ids,JSONObject msg){
		Applogger.instance().getLogger().info(JsonUtils.object2String(msg));
		PublishTaskPool.Instance.getInstance().submit(new WebPublishTask(ids, msg));
	}
	
}
